package com.tree.userservice.sao;

import com.tree.userservice.sao.dto.User;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * package com.tree.userservice.sao
 * description:
 *
 * @author tree
 * @date 2019-09-04 17:45
 */
@Slf4j
@Component
public class UserFeignServiceFallbackFactory implements FallbackFactory<UserFeignService> {

    @Override
    public UserFeignService create(Throwable cause) {
        log.warn("fallback ....",cause);
        return new UserFeignService() {
            @Override
            public String index(){
                return "fall back index ";
            }

            @Override
            public User hello(Integer id, String name, Integer age) {
                return new User(1,"未知", 0);
            }

            @Override
            public String hello2(User user) {
                return "fall back hello2 ";
            }

            @Override
            public String time() {
                return "fallback time";
            }

            @Override
            public String longTime() {
                return "fallback long time";
            }

            @Override
            public String randomTime() {
                return "fallback random time";
            }
        };
    }
}
